package com.uye.tattstemp.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.uye.framework.model.IGenericDAO;
import com.uye.framework.util.StringUtils;
import com.uye.tattstemp.model.IProductivityType;
import com.uye.tattstemp.model.hibernate.domainobjects.ProductivityTypeLight;

/**
 * Exposes calls to the service layer for the management of
 * the productivity metrics tracked by the application
 * 
 * @author uye
 */
@Transactional
@Controller
public class MetricsController {

    @Autowired
    private IGenericDAO<IProductivityType, Long> productivityTypeDAO;
    
    
    

    @RequestMapping("/metrics/listProductivityTypes.service")
    public @ResponseBody
    String listProductivityTypes(HttpServletResponse response) {

        ProductivityTypeLight pt = new ProductivityTypeLight();
        pt.setName("Unpaid");
        productivityTypeDAO.save(pt);

        return StringUtils.toJSONString(productivityTypeDAO.getAll())
                .toString();

    }

}
